package com.guardchina.framework.util.exception;

/**
 * 描述：基础异常类
 *
 * @author lwb
 * @date 2019/3/15 13:59
 */
public class BaseException extends RuntimeException {

    /**
     * 错误码
     */
    private int error;

    /**
     * 简短的错误信息，用于展示给用户
     */
    private String shortMessage;

    public BaseException(int error, String shortMessage){
        super(String.format("errorCode[%s]|%s", error, shortMessage));
        this.error = error;
        this.shortMessage = shortMessage;
    }

    public BaseException(int error, String shortMessage, String detailMessage){
        super(String.format("errorCode[%s]|%s--%s", error, shortMessage,detailMessage));
        this.error = error;
        this.shortMessage = shortMessage;
    }

    public BaseException(int error, String shortMessage, Throwable throwable){
        super(String.format("errorCode[%s]|%s", error, shortMessage), throwable);
        this.error = error;
        this.shortMessage = shortMessage;
    }

    public BaseException(int error, String shortMessage, String detailMessage, Throwable throwable){
        super(String.format("errorCode[%s]|%s--%s", error, shortMessage,detailMessage), throwable);
        this.error = error;
        this.shortMessage = shortMessage;
    }

    public int getError(){
        return error;
    }

    public String getShortMessage(){
        return shortMessage;
    }
}
